﻿using Ledict.ConditionExtract.BLL;
using Ledict.ConditionExtract.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Ledict.ConditionExtract.Frm.DataProcess
{
    public partial class DaoChuWindow : Form
    {
        string ccID = string.Empty;
        Express_WordBLL ewbll = new Express_WordBLL();

        public DaoChuWindow(string ccid)
        {
            InitializeComponent();
            ccID = ccid;
        }

        private void btnDC_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            SaveFileDialog saveFileDig = new SaveFileDialog();
            saveFileDig.Filter = "Excel Office2007及以上(*.xlsx)|*.xlsx";
            saveFileDig.FilterIndex = 1;
            saveFileDig.Title = "导出到";
            saveFileDig.OverwritePrompt = true;
            saveFileDig.FileName = ccID + ".xlsx";
            // saveFileDig.InitialDirectory = DesktopDirectory;
            //string filePath = null;
            if (saveFileDig.ShowDialog() == DialogResult.OK)
            {
                string filePath = saveFileDig.FileName;
                //争议焦点
                if (rbtnDQ.Checked)
                {
                    DataSet dt = ewbll.DaoChuData(ccID, 1);
                    ExcelHelper.ExportToExcel(dt, filePath);
                    MessageBox.Show("导出表数据成功！");
                }
                else if (rbtnAll.Checked)
                {
                    DataSet dt = ewbll.DaoChuData(ccID, 2);
                    ExcelHelper.ExportToExcel(dt, filePath);
                    MessageBox.Show("导出表数据成功！");
                }
            }
            this.Close();
            this.Cursor = Cursors.Default;

        }
    }
}
